package cn.boysoft.core.server.netty.codec;

import static org.jboss.netty.channel.Channels.pipeline;

import java.util.List;
import java.util.Map;

import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;

import cn.boysoft.core.server.MainServer;

/**
 * @author 付厚俊
 * CreateTime 2013-4-4 下午5:09:32
 */

public class HttpServerPipelineFactory implements ChannelPipelineFactory {
   
    List<String> pipelineHandler;
	@Override
	public ChannelPipeline getPipeline() throws Exception {
		    ChannelPipeline pipeline = pipeline();
		    if(this.pipelineHandler != null){
		    	
		    	for(String key:pipelineHandler){
		    		pipeline.addLast(key,(ChannelHandler)MainServer.getBean(key));
//		    		pipeline.addLast("decoder",(ChannelHandler)MainServer.getBean("decoder"));
//		    		pipeline.addLast("deflater",(ChannelHandler)MainServer.getBean("deflater"));
//		    		pipeline.addLast("jsonRequestDecoder",(ChannelHandler)MainServer.getBean("jsonRequestDecoder"));
//		    		pipeline.addLast("encoder", (ChannelHandler)MainServer.getBean("encoder"));
//		    		pipeline.addLast("jsonResponseEncoder",(ChannelHandler)MainServer.getBean("jsonResponseEncoder"));
//		    		pipeline.addLast("requestHandler",(ChannelHandler)MainServer.getBean("jsonRequestHandler"));	
		    	}
		    }
	        return pipeline;
	}
	public void setPipelineHandler(List<String> pipelineHandler) {
		this.pipelineHandler = pipelineHandler;
	}
	

}
